<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智能公厕 - 登录</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
    <style>
        body {
            margin: 0;
            padding: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }

        .page-title {
            color: #2c3e50;
            font-size: 28px;
            margin-bottom: 30px;
            font-weight: 600;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        }

        .login-container {
            background: white;
            padding: 30px;
            border-radius: 16px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
            width: 90%;
            max-width: 360px;
            transition: transform 0.3s ease;
        }

        .login-container:hover {
            transform: translateY(-5px);
        }

        .login-form {
            margin: 0 auto;
        }

        .login-type {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin-bottom: 25px;
        }

        .type-btn {
            padding: 8px 20px;
            border: 2px solid #3498db;
            background: transparent;
            color: #3498db;
            border-radius: 25px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
            font-size: 14px;
        }

        .type-btn:hover {
            background: #3498db15;
        }

        .type-btn.active {
            background: #3498db;
            color: white;
        }

        .form-item {
            margin-bottom: 20px;
            position: relative;
        }

        .form-item i {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #95a5a6;
        }

        .form-item input {
            width: 100%;
            padding: 12px 12px 12px 40px;
            border: 2px solid #e0e0e0;
            border-radius: 25px;
            box-sizing: border-box;
            font-size: 14px;
            transition: all 0.3s ease;
        }

        .form-item input:focus {
            border-color: #3498db;
            outline: none;
            box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
        }

        .login-btn {
            width: 100%;
            padding: 12px;
            background: #3498db;
            color: white;
            border: none;
            border-radius: 25px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 15px rgba(52,152,219,0.2);
        }

        .login-btn:hover {
            background: #2980b9;
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(52,152,219,0.3);
        }

        .login-btn:active {
            transform: translateY(0);
        }

        .about-link {
            text-align: center;
            margin-top: 25px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }

        .about-link a {
            color: #7f8c8d;
            text-decoration: none;
            font-size: 14px;
            transition: all 0.3s ease;
            padding: 5px 10px;
            border-radius: 15px;
        }

        .about-link a:hover {
            color: #3498db;
            background: #ecf0f1;
        }

        /* 添加加载动画 */
        .login-btn.loading {
            position: relative;
            color: transparent;
        }

        .login-btn.loading::after {
            content: "";
            position: absolute;
            width: 20px;
            height: 20px;
            top: 50%;
            left: 50%;
            margin: -10px 0 0 -10px;
            border: 3px solid rgba(255,255,255,0.3);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }
    </style>
    <script src="js/toast.js"></script>
</head>
<body>
    <h1 class="page-title">智能公厕</h1>
    <div class="login-container">
        <div class="login-form">
            <div class="login-type">
                <button class="type-btn" onclick="switchType('user')">用户登录</button>
                <button class="type-btn active" onclick="switchType('admin')">管理员登录</button>
            </div>
            <div class="form-item">
                <i class="fas fa-user"></i>
                <input type="text" id="username" placeholder="请输入用户名" value="admin">
            </div>
            <div class="form-item">
                <i class="fas fa-lock"></i>
                <input type="password" id="password" placeholder="请输入密码" value="admin">
            </div>
            <button class="login-btn" onclick="login(this)">登录</button>
        </div>
        <div class="about-link">
            <a href="index.html">
                <i class="fas fa-info-circle"></i>
                关于我们
            </a>
        </div>
    </div>

    <script>
        function switchType(type) {
            const btns = document.querySelectorAll('.type-btn');
            btns.forEach(btn => btn.classList.remove('active'));
            event.target.classList.add('active');
            
            const username = document.getElementById('username');
            const password = document.getElementById('password');
            
            // 添加过渡动画
            username.style.transition = 'all 0.3s';
            password.style.transition = 'all 0.3s';
            
            if (type === 'admin') {
                username.value = 'admin';
                password.value = 'admin';
            } else {
                username.value = 'user1';
                password.value = 'user1';
            }
        }

        function login(btn) {
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;

            // 添加加载动画
            btn.classList.add('loading');
            btn.disabled = true;

            setTimeout(() => {
                if (username === 'admin' && password === 'admin') {
                    localStorage.setItem('isLoggedIn', 'true');
                    localStorage.setItem('isAdmin', 'true');
                    showToast('登录成功', 'success');
                    setTimeout(() => {
                        window.location.href = 'home.html';
                    }, 1000);
                } else if (username === 'user1' && password === 'user1') {
                    localStorage.setItem('isLoggedIn', 'true');
                    localStorage.setItem('isAdmin', 'false');
                    showToast('登录成功', 'success');
                    setTimeout(() => {
                        window.location.href = 'home.html';
                    }, 1000);
                } else {
                    showToast('用户名或密码错误', 'error');
                    btn.classList.remove('loading');
                    btn.disabled = false;
                }
            }, 800); // 添加一个小延迟使加载动画更明显
        }
    </script>
</body>
</html> 